package manager.modulo.financeiro;

import java.awt.event.KeyEvent;
import java.sql.SQLException;
import java.util.LinkedList;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.table.TableRowSorter;
import manager.auxiliares.AutoComplete;
import manager.auxiliares.Configurations;
import manager.auxiliares.Format;
import manager.auxiliares.Icons;
import manager.auxiliares.MensagemExcessao;
import manager.auxiliares.WindowsFunctions;
import manager.helpers.table.TableModel;
import manager.helpers.table.TableRender;
import manager.helpers.table.TableRowComparator;
import manager.helpers.validation.FormatedFieldValidator;
import manager.helpers.validation.TextFieldValidator;
import manager.helpers.validation.ValidationFunctions;
import manager.principal.fonte.JanelaLogin;
import manager.interfaces.InterfaceTable;
import manager.modulo.financeiro.dao.EntryDescriptionSecondaryCategory;
import manager.modulo.financeiro.dao.FinancialCategoryDao;
import manager.modulo.financeiro.dao.SecondaryCategoryDao;
import manager.modulo.financeiro.dao.EntryTypeDao;
import manager.modulo.financeiro.dao.FinancialEntryDao;
import manager.modulo.financeiro.dao.FinancialEntryDescriptionDao;
import manager.modulo.financeiro.dao.FinancialEntryPartnerDao;
import manager.modulo.clientefornecedor.dao.ClienteFornecedorDao;

/**
 *
 * @author Thiago
 */
public class JanelaEntradaFinanceiro extends javax.swing.JFrame {

    //Financial Entry
    int idFinancialEntry = 0;
    int totalValue = 0;
    int availableValue = 0;
    int unvailableValue = 0;
    AutoComplete autoCompletePartner;
    //EntryDescription
    int idEntryDescription = 0;
    int idIndex = 0;
    TableModel tableModel;
    TableRender tableRender;
    TableRowSorter tableRowSorter;
    LinkedList<EntryDescriptionObject> entryDescriptionList;
    AutoComplete autoCompleteSecondaryCategory;

    public class EntryDescriptionObject {

        int idEntryDescription;
        int situation;
        int value;
        int idSecondaryCategory;
        String valueDescription;
        String dateDescription;
        String messageDescription;
        String secondaryCategoryDescription;

        public EntryDescriptionObject() {
            idEntryDescription = 0;
            situation = 0;
            value = 0;
            idSecondaryCategory = 0;
            valueDescription = "";
            dateDescription = "";
            messageDescription = "";
            secondaryCategoryDescription = "";
        }

        public String getDateDescription() {
            return dateDescription;
        }

        public void setDateDescription(String dateDescription) {
            this.dateDescription = dateDescription;
        }

        public int getIdEntryDescription() {
            return idEntryDescription;
        }

        public void setIdEntryDescription(int idEntryDescription) {
            this.idEntryDescription = idEntryDescription;
        }

        public int getIdSecondaryCategory() {
            return idSecondaryCategory;
        }

        public void setIdSecondaryCategory(int idSecondaryCategory) {
            this.idSecondaryCategory = idSecondaryCategory;
        }

        public String getMessageDescription() {
            return messageDescription;
        }

        public void setMessageDescription(String messageDescription) {
            this.messageDescription = messageDescription;
        }

        public String getSecondaryCategoryDescription() {
            return secondaryCategoryDescription;
        }

        public void setSecondaryCategoryDescription(String secondaryCategoryDescription) {
            this.secondaryCategoryDescription = secondaryCategoryDescription;
        }

        public int getSituation() {
            return situation;
        }

        public void setSituation(int situation) {
            this.situation = situation;
        }

        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public String getValueDescription() {
            return valueDescription;
        }

        public void setValueDescription(String valueDescription) {
            this.valueDescription = valueDescription;
        }
    }

    /**
     * Creates new form UserWindow
     */
    public JanelaEntradaFinanceiro(int newIdFinancialEntry) {
        try {
            // Define layout de acordo com o SO que estiver rodando
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            this.setIconImage(JanelaLogin.icon);
            initComponents();
            idFinancialEntry = newIdFinancialEntry;
            configureWindow();
            this.setLocationRelativeTo(null);
            this.setVisible(true);
        } catch (Exception e) {
            MensagemExcessao.mostrarMensagem(e, this.getTitle());
        }
    }

    private LinkedList<String> getColumnNameEntryDescription() {
        LinkedList<String> columnNames = new LinkedList<String>();
        columnNames.add("");
        columnNames.add("Data");
        columnNames.add("Valor");
        columnNames.add("Subcategoria");
        columnNames.add("Descrição");
        columnNames.add("Situação");
        return columnNames;
    }

    private void setEditEntryDescription(int idEntryDescription) {
        this.idEntryDescription = idEntryDescription;
        jButton2.setToolTipText("Editar");
        jButton2.setIcon(new Icons().getEdit());
        EntryDescriptionObject entryDescriptionObject = entryDescriptionList.get(idIndex);
        jFormattedTextField4.setText(entryDescriptionObject.getValueDescription());
        jFormattedTextField2.setText(entryDescriptionObject.getDateDescription());
        jTextField8.setText(entryDescriptionObject.getSecondaryCategoryDescription());
        jComboBox1.setSelectedItem(FinancialEntryDescriptionDao.getSituation(jComboBox2.getSelectedItem().toString(), entryDescriptionObject.getSituation()));
        jTextField9.setText(entryDescriptionObject.getMessageDescription());
        checkEntryDescriptionRequiredFields();
        jScrollPane3.setVisible(false);
        jButton3.setEnabled(true);
        jButton4.setEnabled(true);
        jFormattedTextField4.requestFocus();
    }

    private void configureTable() {
        tableRender = new TableRender();
        tableModel = new TableModel(getColumnNameEntryDescription(), tableRender, new InterfaceTable() {
            public void tableAction(int id, int columnIndex, int rowIndex) {
                if (columnIndex < 0) {
                    idIndex = rowIndex;
                    setEditEntryDescription(id);
                }
            }

            public boolean isEditableColumn(int columnIndex) {
                if (columnIndex == 0) {
                    return true;
                }
                return false;
            }
        });
        jTable1.setModel(tableModel);
        jTable1.getColumnModel().getColumn(0).setMaxWidth(30);
        jTable1.getColumnModel().getColumn(0).setMinWidth(30);
        jTable1.getColumnModel().getColumn(0).setResizable(false);
        jTable1.getColumnModel().getColumn(1).setMaxWidth(60);
        jTable1.getColumnModel().getColumn(1).setMinWidth(60);
        jTable1.getColumnModel().getColumn(1).setResizable(false);
        jTable1.getColumnModel().getColumn(2).setMaxWidth(80);
        jTable1.getColumnModel().getColumn(2).setMinWidth(80);
        jTable1.getColumnModel().getColumn(2).setResizable(false);
        jTable1.getColumnModel().getColumn(5).setMaxWidth(80);
        jTable1.getColumnModel().getColumn(5).setMinWidth(80);
        jTable1.getColumnModel().getColumn(5).setResizable(false);
        TableRowComparator tableRowComparator = new TableRowComparator();
        tableRowSorter = tableRowComparator;
        jTable1.setRowSelectionAllowed(false);

        searchTable();
    }

    private void checkRequiredFields() {
        ((TextFieldValidator) jTextField1).validarCampo();
        ((FormatedFieldValidator) jFormattedTextField1).validarCampo();
        ((FormatedFieldValidator) jFormattedTextField3).validarCampo();
        ((TextFieldValidator) jTextField4).validarCampo();
        checkEntryDescriptionRequiredFields();
    }

    private void checkEntryDescriptionRequiredFields() {
        ((FormatedFieldValidator) jFormattedTextField4).validarCampo();
        ((FormatedFieldValidator) jFormattedTextField2).validarCampo();
        ((TextFieldValidator) jTextField8).validarCampo();
        ((TextFieldValidator) jTextField9).validarCampo();
    }

    private void resetEntryDescriptionFields() {
        idEntryDescription = 0;
        idIndex = 0;

        jFormattedTextField4.setValue(0);
        jFormattedTextField2.setText(Format.getCurrentVisualDate());
        jTextField8.setText("");
        jScrollPane3.setVisible(false);
        jTextField9.setText("");

        jButton2.setToolTipText("Adicionar");
        jButton2.setIcon(new Icons().getAdd());
        jButton3.setEnabled(false);
        jButton4.setEnabled(false);

        jComboBox1.setSelectedIndex(0);

        checkEntryDescriptionRequiredFields();
    }

    private void searchTable() {
        LinkedList searchResult = new LinkedList();

        LinkedList<Integer> columnId = new LinkedList<Integer>();
        LinkedList<String> columnDate = new LinkedList<String>();
        LinkedList<String> columnValue = new LinkedList<String>();
        LinkedList<String> columnSecondaryCategory = new LinkedList<String>();
        LinkedList<String> columnDescription = new LinkedList<String>();
        LinkedList<String> columnSituation = new LinkedList<String>();

        for (int i = 0; i < entryDescriptionList.size(); i++) {
            EntryDescriptionObject entryDescriptionObject = entryDescriptionList.get(i);
            columnId.add(entryDescriptionObject.getIdEntryDescription());
            columnDate.add(entryDescriptionObject.getDateDescription());
            columnValue.add(entryDescriptionObject.getValueDescription());
            columnSecondaryCategory.add(entryDescriptionObject.getSecondaryCategoryDescription());
            columnDescription.add(entryDescriptionObject.getMessageDescription());
            columnSituation.add(FinancialEntryDescriptionDao.getSituation(jComboBox2.getSelectedItem().toString(), entryDescriptionObject.getSituation()));
        }

        if (entryDescriptionList.size() > 0) {
            searchResult.add(columnId);
            searchResult.add(Format.getBooleanLinkedList(columnId.size()));
            searchResult.add(columnDate);
            searchResult.add(columnValue);
            searchResult.add(columnSecondaryCategory);
            searchResult.add(columnDescription);
            searchResult.add(columnSituation);
        }

        tableModel.update(searchResult);
        jTable1.setDefaultRenderer(Object.class, tableRender);
        tableRowSorter.setModel(tableModel);

        jTable1.setRowSorter(tableRowSorter);
    }

    private LinkedList<String> validateEntryDescriptionFields() {
        LinkedList<String> fieldList = new LinkedList<String>();
        if (!((FormatedFieldValidator) jFormattedTextField4).validarCampo()) {
            fieldList.add(((FormatedFieldValidator) jFormattedTextField4).getjLabel().getText());
        }
        if (!((FormatedFieldValidator) jFormattedTextField2).validarCampo()) {
            fieldList.add(((FormatedFieldValidator) jFormattedTextField2).getjLabel().getText());
        }
        if (!((TextFieldValidator) jTextField9).validarCampo()) {
            fieldList.add(((TextFieldValidator) jTextField9).getjLabel().getText());
        }
        if (SecondaryCategoryDao.getIdSecondaryCategoryByName(jTextField8.getText()) == 0) {
            fieldList.add(((TextFieldValidator) jTextField8).getjLabel().getText());
        }
        return fieldList;
    }

    private LinkedList<String> validateFinancialEntryFields() {
        LinkedList<String> fieldList = new LinkedList<String>();
        if (!((TextFieldValidator) jTextField1).validarCampo()) {
            fieldList.add(((TextFieldValidator) jTextField1).getjLabel().getText());
        }
        if (!((TextFieldValidator) jTextField4).validarCampo()) {
            fieldList.add(((TextFieldValidator) jTextField4).getjLabel().getText());
        }
        if (!((FormatedFieldValidator) jFormattedTextField1).validarCampo()) {
            fieldList.add(((FormatedFieldValidator) jFormattedTextField1).getjLabel().getText());
        }
        if (!((FormatedFieldValidator) jFormattedTextField3).validarCampo()) {
            fieldList.add(((FormatedFieldValidator) jFormattedTextField3).getjLabel().getText());
        }
        return fieldList;
    }

    private int addFinancialEntry() {
        try {
            calculateFinancialEntryValues();
            if ((totalValue < availableValue) || (totalValue < (availableValue + unvailableValue))) {
                JOptionPane.showMessageDialog(null, "O valor total não pode ser menor que o valor a ser pago.", this.getTitle(), JOptionPane.ERROR_MESSAGE);
            } else {
                try {
                    if (totalValue != availableValue + unvailableValue) {
                        Object[] options = {"Sim", "Não"};
                        int j = JOptionPane.showOptionDialog(null, "O valor de descrições está menor que o valor total. Clique em (Sim) para que o sistema cadastre uma descrição automática para você, ou clique em (Não) para voltar a edição de lançamento.", this.getTitle(), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
                        if (j == JOptionPane.NO_OPTION) {
                            return 0;
                        }
                    }
                    JanelaLogin.connection.setAutoCommit(false);

                    FinancialEntryDao financialEntryDao = new FinancialEntryDao();
                    financialEntryDao.setIdBudget(1);
                    financialEntryDao.setIdEntryType(EntryTypeDao.getIdEntryTypeByName(jComboBox2.getSelectedItem().toString()));
                    financialEntryDao.setValue((int) (((Number) jFormattedTextField3.getValue()).doubleValue() * 100));
                    financialEntryDao.setDate(jFormattedTextField1.getText());
                    financialEntryDao.setSituation(FinancialEntryDao.getSituation(jComboBox3.getSelectedItem().toString()));
                    financialEntryDao.setDescription(jTextField4.getText());
                    financialEntryDao.inserir();

                    if (jCheckBox1.isSelected()) {
                        FinancialEntryPartnerDao financialEntryPartnerDao = new FinancialEntryPartnerDao();
                        financialEntryPartnerDao.setIdFinancialEntry(financialEntryDao.getId());
                        financialEntryPartnerDao.setIdPartner(ClienteFornecedorDao.getIdClienteFornecedorPorIdentificador(jTextField1.getText()));
                        financialEntryPartnerDao.inserir();
                    }

                    int currentAvailableValue = 0;
                    EntryDescriptionObject entryDescriptionObject;
                    FinancialEntryDescriptionDao financialEntryDescriptionDao;
                    EntryDescriptionSecondaryCategory entryDescriptionSecondaryCategory;
                    for (int i = 0; i < entryDescriptionList.size(); i++) {
                        entryDescriptionObject = entryDescriptionList.get(i);
                        financialEntryDescriptionDao = new FinancialEntryDescriptionDao();
                        financialEntryDescriptionDao.setDate(entryDescriptionObject.getDateDescription());
                        financialEntryDescriptionDao.setValue(entryDescriptionObject.getValue());
                        financialEntryDescriptionDao.setDescription(entryDescriptionObject.getMessageDescription());
                        financialEntryDescriptionDao.setSituation(entryDescriptionObject.getSituation());
                        financialEntryDescriptionDao.inserir();
                        if (financialEntryDescriptionDao.getSituation() == 1) {
                            currentAvailableValue += financialEntryDescriptionDao.getValue();
                        }

                        entryDescriptionSecondaryCategory = new EntryDescriptionSecondaryCategory(entryDescriptionObject.getIdSecondaryCategory(), financialEntryDescriptionDao.getId());
                        entryDescriptionSecondaryCategory.inserir();
                    }

                    if ((currentAvailableValue + unvailableValue) != totalValue) {// Verificando se as descrições estão menor que o valor total
                        financialEntryDescriptionDao = new FinancialEntryDescriptionDao();
                        financialEntryDescriptionDao.setDate(Format.getCurrentVisualDate());
                        financialEntryDescriptionDao.setValue(totalValue - (currentAvailableValue + unvailableValue));
                        financialEntryDescriptionDao.setDescription("NÃO INFORMADO");
                        financialEntryDescriptionDao.setSituation(1);
                        financialEntryDescriptionDao.inserir();
                    }

                    JanelaLogin.connection.commit();
                    JOptionPane.showMessageDialog(null, "Categoria cadastrada com sucesso.", this.getTitle(), JOptionPane.INFORMATION_MESSAGE);
                    this.dispose();
                } catch (Exception e) {
                    JanelaLogin.connection.rollback();
                    MensagemExcessao.mostrarMensagem(e, this.getTitle());
                } finally {
                    JanelaLogin.connection.setAutoCommit(true);
                }

            }
        } catch (Exception ex) {
            MensagemExcessao.mostrarMensagem(ex, this.getTitle());
        }
        return 0;
    }

    private void editFinancialEntry() {
        try {
            FinancialCategoryDao financialCategoryDao = new FinancialCategoryDao();
            financialCategoryDao.buscar(idFinancialEntry);
            if (FinancialCategoryDao.getIdCategoryByName(jTextField1.getText()) == 0 || financialCategoryDao.getName().equals(jTextField1.getText())) {
                try {
                    JanelaLogin.connection.setAutoCommit(false);


                    financialCategoryDao.setName(jTextField1.getText());
                    financialCategoryDao.setIdEntryType(EntryTypeDao.getIdEntryTypeByName(jComboBox2.getSelectedItem().toString()));
                    financialCategoryDao.atualizar();

                    LinkedList tableData = tableModel.getData();
                    LinkedList<Integer> listId = tableModel.getIdList();
                    LinkedList<String> listName = ((LinkedList<String>) tableData.get(1));
                    LinkedList<String> listSituation = ((LinkedList<String>) tableData.get(2));

                    boolean validate = true;
                    String message = "";

                    for (int i = 0; i < listId.size(); i++) {
                        SecondaryCategoryDao secondaryCategoryDao = new SecondaryCategoryDao();
                        secondaryCategoryDao.setId(listId.get(i));
                        if (secondaryCategoryDao.getId() > 0) {//Esta subcategoria já esta cadastrada
                            secondaryCategoryDao.buscar(secondaryCategoryDao.getId());
                            secondaryCategoryDao.setName(listName.get(i));
                            secondaryCategoryDao.setSituation(SecondaryCategoryDao.getSituation(listSituation.get(i)));
                            secondaryCategoryDao.setIdFinancialCategory(idFinancialEntry);
                            int idSearchSecondary = SecondaryCategoryDao.getIdSecondaryCategoryByName(secondaryCategoryDao.getName());
                            if (idSearchSecondary == 0 || idSearchSecondary == secondaryCategoryDao.getId()) {
                                secondaryCategoryDao.atualizar();
                            } else {
                                validate = false;
                                message = "A subcategoria (" + secondaryCategoryDao.getName() + ") pertence a outra categoria.";
                                i = tableData.size();
                            }
                        } else {//Nova subcategoria
                            secondaryCategoryDao.setName(listName.get(i));
                            secondaryCategoryDao.setSituation(SecondaryCategoryDao.getSituation(listSituation.get(i)));
                            secondaryCategoryDao.setIdFinancialCategory(idFinancialEntry);
                            int idSearchSecondary = SecondaryCategoryDao.getIdSecondaryCategoryByName(secondaryCategoryDao.getName());
                            if (idSearchSecondary == 0) {
                                secondaryCategoryDao.inserir();
                            } else {
                                validate = false;
                                message = "A subcategoria (" + secondaryCategoryDao.getName() + ") pertence a outra categoria.";
                                i = tableData.size();
                            }
                        }
                    }
                    if (validate) {
                        JanelaLogin.connection.commit();
                        JOptionPane.showMessageDialog(null, "Categoria editada com sucesso.", this.getTitle(), JOptionPane.INFORMATION_MESSAGE);
                        this.dispose();
                    } else {
                        JanelaLogin.connection.rollback();
                        JOptionPane.showMessageDialog(null, message, this.getTitle(), JOptionPane.INFORMATION_MESSAGE);
                    }
                } catch (Exception e) {
                    JanelaLogin.connection.rollback();
                    MensagemExcessao.mostrarMensagem(e, this.getTitle());
                } finally {
                    JanelaLogin.connection.setAutoCommit(true);
                }
            } else {
                JOptionPane.showMessageDialog(null, "Este email já esta cadastrado.", this.getTitle(), JOptionPane.ERROR_MESSAGE);
            }
        } catch (Exception ex) {
            MensagemExcessao.mostrarMensagem(ex, this.getTitle());
        }
    }

    private void setEntryDescription(String type) {
        try {
            EntryDescriptionObject entryDescriptionObject = (idEntryDescription == 0) ? new EntryDescriptionObject() : entryDescriptionList.get(idIndex);
            entryDescriptionObject.setDateDescription(jFormattedTextField2.getText());
            entryDescriptionObject.setValue((int) (((Number) jFormattedTextField4.getValue()).doubleValue() * 100));
            entryDescriptionObject.setIdSecondaryCategory(SecondaryCategoryDao.getIdSecondaryCategoryByName(jTextField8.getText()));
            entryDescriptionObject.setSecondaryCategoryDescription(jTextField8.getText());
            entryDescriptionObject.setSituation(getEntryDescriptionSituation(jComboBox1.getSelectedItem().toString()));
            entryDescriptionObject.setValueDescription(Format.formatarMonetario(Double.toString(((double) entryDescriptionObject.getValue()) / 100)));
            entryDescriptionObject.setMessageDescription(jTextField9.getText());
            if (type.equalsIgnoreCase("add")) {
                entryDescriptionObject.setIdEntryDescription((entryDescriptionList.size() + 1) * -1);
                entryDescriptionList.add(entryDescriptionObject);
            } else {
                entryDescriptionList.set(idIndex, entryDescriptionObject);
            }
            resetEntryDescriptionFields();

            searchTable();

            calculateFinancialEntryValues();
        } catch (Exception ex) {
            MensagemExcessao.mostrarMensagem(ex, this.getTitle());
        }
    }

    private void setEntityInformations() {
        jButton1.setText("Editar");
        jButton1.setIcon(new Icons().getEdit());

        FinancialCategoryDao financialCategoryDao = new FinancialCategoryDao();
        financialCategoryDao.buscar(idFinancialEntry);
        jTextField1.setText(financialCategoryDao.getName());
        jComboBox2.setSelectedItem(EntryTypeDao.getNameByIdEntryType(financialCategoryDao.getIdEntryType()));
        searchTable();
    }

    /**
     * Inicializando as configurações da tela
     *
     * @throws SQLException
     */
    private void configureWindow() throws SQLException {
        autoCompletePartner = new AutoComplete(jList1, jScrollPane2, jTextField1);
        entryDescriptionList = new LinkedList<EntryDescriptionObject>();

        autoCompleteSecondaryCategory = new AutoComplete(jList2, jScrollPane3, jTextField8);


        configureTable();

        LinkedList<String> entryTypes = EntryTypeDao.getListEntryTypes();
        for (int i = 0; i < entryTypes.size(); i++) {
            jComboBox2.addItem(entryTypes.get(i));
        }
        LinkedList<String> entrySituations = FinancialEntryDao.getListSituation();
        for (int i = 0; i < entrySituations.size(); i++) {
            jComboBox3.addItem(entrySituations.get(i));
        }
        if (idFinancialEntry != 0) { // Edição de usuário
            setEntityInformations();
        }
        checkRequiredFields();
    }

    private void calculateFinancialEntryValues() {
        totalValue = (int) (((Number) jFormattedTextField3.getValue()).doubleValue() * 100);
        unvailableValue = 0;
        availableValue = 0;
        for (int i = 0; i < entryDescriptionList.size(); i++) {
            EntryDescriptionObject entryDescriptionObject = entryDescriptionList.get(i);
            if (entryDescriptionObject.getSituation() == 0) {
                unvailableValue += entryDescriptionObject.getValue();
            } else {
                availableValue += entryDescriptionObject.getValue();
            }
        }

        jTextField7.setText(Format.formatarMonetario(Double.toString(((double) totalValue) / 100)));
        jTextField6.setText(Format.formatarMonetario(Double.toString(((double) unvailableValue) / 100)));
        jTextField5.setText(Format.formatarMonetario(Double.toString(((double) totalValue - unvailableValue) / 100)));
    }

    private int getEntryDescriptionSituation(String situation) {
        if (situation.equalsIgnoreCase("PAGO") || situation.equalsIgnoreCase("RECEBIDO") || situation.equalsIgnoreCase("MOVIMENTADO")) {
            return 1;
        } else {
            return 0;
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new manager.helpers.validation.TextFieldValidator(80,-1,true,true,"text",jLabel1);
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jFormattedTextField2 = new FormatedFieldValidator(true, true, "date", jLabel12);
        jLabel13 = new javax.swing.JLabel();
        jTextField8 = new TextFieldValidator(-1, -1, true, true, "text", jLabel13);
        jLabel14 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jTextField9 = new TextFieldValidator(200, -1, true, true, "text", jLabel14);
        jButton4 = new javax.swing.JButton();
        jFormattedTextField4 = new FormatedFieldValidator(true, true, "money", jLabel2);
        jButton5 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jCheckBox1 = new javax.swing.JCheckBox();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jFormattedTextField1 = new FormatedFieldValidator(true, true, "date", jLabel6);
        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jLabel7 = new javax.swing.JLabel();
        jTextField4 = new TextFieldValidator(200, -1, true, true, "text", jLabel7);
        jComboBox3 = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jFormattedTextField3 = new FormatedFieldValidator(true, true, "money", jLabel5);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Lançamentos Financeiros");
        setBackground(Configurations.getBackGroundColor());
        setMinimumSize(new java.awt.Dimension(601, 450));
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });

        jPanel3.setBackground(Configurations.getBackGroundColor());
        jPanel3.setPreferredSize(new java.awt.Dimension(700, 320));
        jPanel3.setLayout(null);

        jPanel1.setBackground(Configurations.getBackGroundColor());
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel1.setLayout(null);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel1.setText("Parceiro");
        jPanel1.add(jLabel1);
        jLabel1.setBounds(180, 20, 150, 14);

        jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField1KeyReleased(evt);
            }
        });
        jPanel1.add(jTextField1);
        jTextField1.setBounds(160, 40, 240, 20);

        jPanel2.setBackground(Configurations.getBackGroundColor());
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("DESCRIÇÃO DOS LANÇAMENTOS"));
        jPanel2.setLayout(null);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Valor");
        jPanel2.add(jLabel2);
        jLabel2.setBounds(10, 20, 80, 14);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/manager/images/add.png"))); // NOI18N
        jButton2.setToolTipText("Adicionar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton2);
        jButton2.setBounds(500, 30, 30, 30);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/manager/images/cancel.png"))); // NOI18N
        jButton3.setToolTipText("Cancelar");
        jButton3.setEnabled(false);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton3);
        jButton3.setBounds(540, 30, 30, 30);

        jScrollPane1.setViewportView(jTable1);

        jPanel2.add(jScrollPane1);
        jScrollPane1.setBounds(10, 120, 560, 100);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PAGO", "NÃO PAGO" }));
        jComboBox1.setNextFocusableComponent(jTextField9);
        jPanel2.add(jComboBox1);
        jComboBox1.setBounds(400, 40, 90, 20);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("Situação");
        jPanel2.add(jLabel3);
        jLabel3.setBounds(400, 20, 60, 14);

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel12.setText("Data");
        jPanel2.add(jLabel12);
        jLabel12.setBounds(105, 20, 50, 14);
        jPanel2.add(jFormattedTextField2);
        jFormattedTextField2.setBounds(105, 40, 70, 20);

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel13.setText("Subcategoria");
        jPanel2.add(jLabel13);
        jLabel13.setBounds(180, 20, 90, 14);

        jTextField8.setNextFocusableComponent(jComboBox1);
        jTextField8.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField8KeyReleased(evt);
            }
        });
        jPanel2.add(jTextField8);
        jTextField8.setBounds(180, 40, 180, 20);

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel14.setText("Descrição");
        jPanel2.add(jLabel14);
        jLabel14.setBounds(10, 65, 90, 14);

        jScrollPane3.setVisible(false);

        jList2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jList2MouseReleased(evt);
            }
        });
        jList2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jList2KeyReleased(evt);
            }
        });
        jScrollPane3.setViewportView(jList2);

        jPanel2.add(jScrollPane3);
        jScrollPane3.setBounds(180, 60, 180, 50);

        jTextField9.setNextFocusableComponent(jButton2);
        jPanel2.add(jTextField9);
        jTextField9.setBounds(10, 85, 480, 20);

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/manager/images/remove.png"))); // NOI18N
        jButton4.setToolTipText("Remover");
        jButton4.setEnabled(false);
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton4);
        jButton4.setBounds(520, 70, 30, 30);

        jFormattedTextField4.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jPanel2.add(jFormattedTextField4);
        jFormattedTextField4.setBounds(10, 40, 90, 20);

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/manager/images/search.png"))); // NOI18N
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton5);
        jButton5.setBounds(365, 38, 30, 23);

        jPanel1.add(jPanel2);
        jPanel2.setBounds(10, 180, 580, 230);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/manager/images/add.png"))); // NOI18N
        jButton1.setText("Cadastrar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton1);
        jButton1.setBounds(20, 420, 100, 23);

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/manager/images/cancel.png"))); // NOI18N
        jButton6.setText("Cancelar");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton6);
        jButton6.setBounds(130, 420, 100, 23);

        jComboBox2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBox2ItemStateChanged(evt);
            }
        });
        jPanel1.add(jComboBox2);
        jComboBox2.setBounds(20, 40, 130, 20);

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("Tipo de Lançamento");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(20, 20, 120, 14);

        jCheckBox1.setBackground(Configurations.getBackGroundColor());
        jCheckBox1.setSelected(true);
        jCheckBox1.setFocusable(false);
        jCheckBox1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCheckBox1ItemStateChanged(evt);
            }
        });
        jPanel1.add(jCheckBox1);
        jCheckBox1.setBounds(155, 20, 20, 15);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("Valor");
        jPanel1.add(jLabel5);
        jLabel5.setBounds(405, 20, 60, 14);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("Data");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(510, 20, 60, 14);

        jFormattedTextField1.setNextFocusableComponent(jTextField4);
        jPanel1.add(jFormattedTextField1);
        jFormattedTextField1.setBounds(510, 40, 70, 20);

        jScrollPane2.setVisible(false);

        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jList1MouseReleased(evt);
            }
        });
        jList1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jList1KeyReleased(evt);
            }
        });
        jScrollPane2.setViewportView(jList1);

        jPanel1.add(jScrollPane2);
        jScrollPane2.setBounds(160, 60, 240, 50);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("Descrição");
        jPanel1.add(jLabel7);
        jLabel7.setBounds(160, 70, 70, 14);

        jTextField4.setNextFocusableComponent(jFormattedTextField4);
        jTextField4.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField4FocusLost(evt);
            }
        });
        jPanel1.add(jTextField4);
        jTextField4.setBounds(160, 90, 420, 20);

        jPanel1.add(jComboBox3);
        jComboBox3.setBounds(20, 90, 130, 20);

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel10.setText("Situação");
        jPanel1.add(jLabel10);
        jLabel10.setBounds(20, 70, 70, 14);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel8.setText("Valor Pago");
        jPanel1.add(jLabel8);
        jLabel8.setBounds(80, 120, 120, 14);

        jTextField5.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jTextField5.setEnabled(false);
        jPanel1.add(jTextField5);
        jTextField5.setBounds(80, 140, 120, 20);

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel9.setText("Valor a Pagar");
        jPanel1.add(jLabel9);
        jLabel9.setBounds(240, 120, 120, 14);

        jTextField6.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jTextField6.setEnabled(false);
        jPanel1.add(jTextField6);
        jTextField6.setBounds(240, 140, 120, 20);

        jTextField7.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jTextField7.setEnabled(false);
        jPanel1.add(jTextField7);
        jTextField7.setBounds(400, 140, 120, 20);

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel11.setText("Valor Total");
        jPanel1.add(jLabel11);
        jLabel11.setBounds(400, 120, 120, 14);

        jFormattedTextField3.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jFormattedTextField3.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jFormattedTextField3FocusLost(evt);
            }
        });
        jPanel1.add(jFormattedTextField3);
        jFormattedTextField3.setBounds(405, 40, 100, 20);

        jPanel3.add(jPanel1);
        jPanel1.setBounds(0, 0, 600, 450);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
        WindowsFunctions.resizePanel(jPanel3, jPanel1);
    }//GEN-LAST:event_formComponentResized

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        LinkedList<String> fieldValidadeList = validateFinancialEntryFields();
        if (fieldValidadeList.size() == 0) {
            if (idFinancialEntry == 0) {
                addFinancialEntry();
            } else {
                editFinancialEntry();
            }
        } else {
            JOptionPane.showMessageDialog(null, ValidationFunctions.getValidationMessage(fieldValidadeList), this.getTitle(), JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        LinkedList<String> fieldValidadeList = validateEntryDescriptionFields();
        if (fieldValidadeList.size() == 0) {
            if (idEntryDescription == 0) {
                setEntryDescription("add");
            } else {
                setEntryDescription("edit");
            }
        } else {
            JOptionPane.showMessageDialog(null, ValidationFunctions.getValidationMessage(fieldValidadeList), this.getTitle(), JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        resetEntryDescriptionFields();
}//GEN-LAST:event_jButton3ActionPerformed

    private void jCheckBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCheckBox1ItemStateChanged
        TextFieldValidator textFieldValidator = (TextFieldValidator) jTextField1;
        if (jCheckBox1.isSelected()) {
            textFieldValidator.setEnabled(true);
            textFieldValidator.setIsRequired(true);
            textFieldValidator.validarCampo();
            textFieldValidator.requestFocus();
        } else {
            textFieldValidator.setText("");
            textFieldValidator.setEnabled(false);
            textFieldValidator.setIsRequired(false);
            textFieldValidator.validarCampo();
            jScrollPane2.setVisible(false);
        }
    }//GEN-LAST:event_jCheckBox1ItemStateChanged

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
//        if (cityWindow != null) {
//            cityWindow.dispose();
//        }
//        cityWindow = new CityWindow();
}//GEN-LAST:event_jButton5ActionPerformed

    private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyReleased
        try {
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                if (ClienteFornecedorDao.getIdClienteFornecedorPorIdentificador(jTextField1.getText()) != 0) {
                    jTextField1.transferFocus();
                }
            } else if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
                if (autoCompletePartner.getjScrollPane().isVisible()) {
                    autoCompletePartner.getjList().setSelectedIndex(0);
                    autoCompletePartner.getjList().requestFocus();
                }
            } else {
                if (!autoCompletePartner.getSearchWord().equals(jTextField1.getText())) {
                    autoCompletePartner.setSearchWord(jTextField1.getText());
                    autoCompletePartner.update(new ClienteFornecedorDao().buscar("Apelido", jTextField1.getText(), true));
                }
            }
        } catch (Exception e) {
            MensagemExcessao.mostrarMensagem(e, this.getTitle());
        }
    }//GEN-LAST:event_jTextField1KeyReleased

    private void jList1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jList1KeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            autoCompletePartner.setSearchWord(autoCompletePartner.getjList().getSelectedValue().toString());
            autoCompletePartner.getjScrollPane().setVisible(false);
            jFormattedTextField3.requestFocus();
        }
    }//GEN-LAST:event_jList1KeyReleased

    private void jList1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseReleased
        autoCompletePartner.setSearchWord(autoCompletePartner.getjList().getSelectedValue().toString());
        autoCompletePartner.getjScrollPane().setVisible(false);
        jFormattedTextField3.requestFocus();
    }//GEN-LAST:event_jList1MouseReleased

    private void jComboBox2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox2ItemStateChanged
        String type = jComboBox2.getSelectedItem().toString();
        if (type.equalsIgnoreCase("DESPESA")) {
            jLabel8.setText("Valor Pago");
            jLabel9.setText("Valor a Pagar");

            jComboBox1.removeAllItems();
            jComboBox1.addItem("PAGO");
            jComboBox1.addItem("NÃO PAGO");
        } else if (type.equalsIgnoreCase("RECEITA")) {
            jLabel8.setText("Valor Recebido");
            jLabel9.setText("Valor a Receber");

            jComboBox1.removeAllItems();
            jComboBox1.addItem("RECEBIDO");
            jComboBox1.addItem("NÃO RECEBIDO");
        } else {
            jLabel8.setText("Valor Movimentado");
            jLabel9.setText("Valor a Movimentar");

            jComboBox1.removeAllItems();
            jComboBox1.addItem("MOVIMENTADO");
            jComboBox1.addItem("NÃO MOVIMENTADO");
        }
        searchTable();
    }//GEN-LAST:event_jComboBox2ItemStateChanged

    private void jFormattedTextField3FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jFormattedTextField3FocusLost
        calculateFinancialEntryValues();
        jFormattedTextField4.setValue(jFormattedTextField3.getValue());
    }//GEN-LAST:event_jFormattedTextField3FocusLost

    private void jList2MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList2MouseReleased
        autoCompleteSecondaryCategory.setSearchWord(autoCompleteSecondaryCategory.getjList().getSelectedValue().toString());
        autoCompleteSecondaryCategory.getjScrollPane().setVisible(false);
        jComboBox1.requestFocus();
    }//GEN-LAST:event_jList2MouseReleased

    private void jList2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jList2KeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            autoCompleteSecondaryCategory.setSearchWord(autoCompleteSecondaryCategory.getjList().getSelectedValue().toString());
            autoCompleteSecondaryCategory.getjScrollPane().setVisible(false);
            jComboBox1.requestFocus();
        }
    }//GEN-LAST:event_jList2KeyReleased

    private void jTextField8KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField8KeyReleased
        try {
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                if (SecondaryCategoryDao.getIdSecondaryCategoryByName(jTextField8.getText()) != 0) {
                    jTextField8.transferFocus();
                }
            } else if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
                if (autoCompleteSecondaryCategory.getjScrollPane().isVisible()) {
                    autoCompleteSecondaryCategory.getjList().setSelectedIndex(0);
                    autoCompleteSecondaryCategory.getjList().requestFocus();
                }
            } else {
                if (!autoCompleteSecondaryCategory.getSearchWord().equals(jTextField8.getText())) {
                    autoCompleteSecondaryCategory.setSearchWord(jTextField8.getText());
                    autoCompleteSecondaryCategory.update(new SecondaryCategoryDao().buscar("Nome", jTextField8.getText(), true));
                }
            }
        } catch (Exception e) {
            MensagemExcessao.mostrarMensagem(e, this.getTitle());
        }
    }//GEN-LAST:event_jTextField8KeyReleased

    private void jTextField4FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField4FocusLost
        jTextField9.setText(jTextField4.getText());
        ((TextFieldValidator) jTextField9).validarCampo();
    }//GEN-LAST:event_jTextField4FocusLost

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        entryDescriptionList.remove(idIndex);
        resetEntryDescriptionFields();
        searchTable();
        calculateFinancialEntryValues();
    }//GEN-LAST:event_jButton4ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JFormattedTextField jFormattedTextField2;
    private javax.swing.JFormattedTextField jFormattedTextField3;
    private javax.swing.JFormattedTextField jFormattedTextField4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    // End of variables declaration//GEN-END:variables
}
